package codelifes.clms;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IAction saveAction;
    private IAction saveAsAction;
    private IAction saveAllAction;
    private IAction copyAction;
    private IAction cutAction;
    private IAction deleteAction;
    private IAction printAction;
    private IAction quitAction;
    private IAction pasteAction;
    private IAction undoAction;
    private IAction redoAction;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    @Override
    protected void makeActions(IWorkbenchWindow window) {
        {
            saveAction = ActionFactory.SAVE.create(window);
            register(saveAction);
        }
        {
            saveAsAction = ActionFactory.SAVE_AS.create(window);
            register(saveAsAction);
        }
        {
            saveAllAction = ActionFactory.SAVE_ALL.create(window);
            register(saveAllAction);
        }
        {
            copyAction = ActionFactory.COPY.create(window);
            register(copyAction);
        }
        {
            cutAction = ActionFactory.CUT.create(window);
            register(cutAction);
        }
        {
            deleteAction = ActionFactory.DELETE.create(window);
            register(deleteAction);
        }
        {
            printAction = ActionFactory.PRINT.create(window);
            register(printAction);
        }
        {
            quitAction = ActionFactory.QUIT.create(window);
            register(quitAction);
        }
        {
            pasteAction = ActionFactory.PASTE.create(window);
            register(pasteAction);
        }
        {
            undoAction = ActionFactory.UNDO.create(window);
            register(undoAction);
        }
        {
            redoAction = ActionFactory.REDO.create(window);
            register(redoAction);
        }
    }

    @Override
    protected void fillMenuBar(IMenuManager menuBar) {

        MenuManager menuManager = new MenuManager("文件");
        menuManager.setVisible(true);
        menuBar.add(menuManager);
        menuManager.add(new Separator());
        menuManager.add(saveAction);
        menuManager.add(saveAllAction);
        menuManager.add(saveAsAction);
        menuManager.add(new Separator());
        menuManager.add(printAction);
        menuManager.add(quitAction);

        MenuManager menuManager_1 = new MenuManager("编辑");
        menuBar.add(menuManager_1);
        menuManager_1.add(undoAction);
        menuManager_1.add(redoAction);
        menuManager_1.add(copyAction);
        menuManager_1.add(cutAction);
        menuManager_1.add(pasteAction);
        menuManager_1.add(deleteAction);

        MenuManager menuManager_2 = new MenuManager("New MenuManager");
        menuBar.add(menuManager_2);

        MenuManager menuManager_3 = new MenuManager("New MenuManager");
        menuBar.add(menuManager_3);

        MenuManager menuManager_4 = new MenuManager("New MenuManager");
        menuBar.add(menuManager_4);
    }

}
